

class Class(object):
    
    def __init__(self, name, data):
        setattr(self, name, data)
    
    def __getattr__(self, name):
        attrs = name.split('.')
        first = attrs[0]
        first_val = getattr(self, first)
        return getattr(first_val, '.'.join(attrs[1:]))
    
    def __setattr__(self, name, value):
        attrs = name.split('.')
        first = attrs[0]
        if len(attrs) > 1:
            val = getattr(self, first)
            setattr(val, '.'.join(attrs[1:]), value)
        else:
            object.__setattr__(self, name, value)
    
obj1 = Class("attr1", 1)
obj2 = Class("attr2", obj1)
obj3 = Class("attr3", obj2)

print getattr(obj3, "attr3.attr2.attr1")
setattr(obj3, "attr3.attr2.attr1", 5)
print getattr(obj3, "attr3.attr2.attr1")
